package com.scrawler.util;



import java.io.UnsupportedEncodingException;


/**  
 * @Description: 描述
 * @author kuntang    
 * @version 1.0  
 * @created 2012-10-29 下午5:37:57 
 * Copyright (c) 2012 sohu,Inc. All Rights Reserved.
 */

public class PathUtil {

	private static final String  BASE_PATH;
	private static final String OS_NAME;
	private static final PathUtil instance = new PathUtil();
	static{
		String path = PathUtil.class.getProtectionDomain().getCodeSource().getLocation().getFile();
		try {
			path = java.net.URLDecoder.decode(path, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		java.io.File jarFile = new java.io.File(path);
		
		if (jarFile != null) {
		path = jarFile.getParentFile().getAbsolutePath();
		}
		BASE_PATH = path;
		OS_NAME = System.getProperty("os.name");
	}
	public static PathUtil getInstance(){
		return instance;
	}
	
	public  String getBasePath(){
		return BASE_PATH;
	}
	
	public String getOsName(){
		return OS_NAME;
	}
	
	/**
	 * @Description:
	 * @Date: 2012-10-29
	 * @param: @param args
	 * @return: void
	 */
	public static void main(String[] args) {
		System.out.println(System.getProperty("os.name"));
	}
}
